package com.rongshu.view.userInfo.adapter.pageadapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.rongshu.view.userInfo.fragment.ShareArticleFragment;
import com.rongshu.view.userInfo.fragment.ShareInvationFragment;
import com.rongshu.view.userInfo.fragment.ShareVoiceFragment;

import java.util.List;

public class ShareArticleInvationVoicePageAdapter extends FragmentPagerAdapter {

    private List<String> titles = null;

    public ShareArticleInvationVoicePageAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setTitles(List<String> list) {
        this.titles = list;
    }

    @Override
    public Fragment getItem(int position) {
        return createForNoExpand(position);
    }

    @Override
    public int getCount() {
        return titles.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    private Fragment createForNoExpand(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
                fragment = new ShareArticleFragment();
                break;
            case 1:
                fragment = new ShareInvationFragment();
                break;
            case 2:
                fragment = new ShareVoiceFragment();
                break;
        }
        return fragment;
    }
}
